<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\ocean;

use app\enum\OeUrlEnum;
use proxy\Client;

class FinanceService extends OceanService
{
    /**
     * 查询账户日流水.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getAdvertiserDailyFlow(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = OeUrlEnum::getServiceName('finance');
            $serviceUrl = OeUrlEnum::getServiceUrl('finance', 'advertiser_daily_stat');

            return $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 自定义报表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getCustomMaterialDailyReport(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = OeUrlEnum::getServiceName('material');
            $serviceUrl = OeUrlEnum::getServiceUrl('material', 'custom_material_report');

            return $client->get($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 视频素材报表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getMaterialDailyReport(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = OeUrlEnum::getServiceName('material');
            $serviceUrl = OeUrlEnum::getServiceUrl('material', 'material_report');

            return $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 图片素材报表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getMaterialIntegratedDailyReport(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = OeUrlEnum::getServiceName('material');
            $serviceUrl = OeUrlEnum::getServiceUrl('material', 'integrated_get');

            return $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取广告账户报表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getAdvertiserReport(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = OeUrlEnum::getServiceName('finance');
            $serviceUrl = OeUrlEnum::getServiceUrl('finance', 'advertiser_report');

            return $client->get($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }
}
